package com.shunwang.caipiao.data.container;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.shunwang.caipiao.vo.NumberIntervalVo;

public class NumberIntervalSeat {

	private List<NumberIntervalVo> list;
	
	public NumberIntervalSeat(int maxNumber){
		list = new ArrayList<NumberIntervalVo>(maxNumber);
		for(int i=1,len=maxNumber;i <= len;i++){
			list.add(new NumberIntervalVo(i));
		}
	}
	/**
	 * 命中的数字+1,没有命中的数字+1
	 * @param i
	 */
	public void hit(int i){
		int realIndex = i-1;
		if(realIndex > 0 && realIndex < list.size()){
			for(int seat=0;seat< list.size();seat++){
				NumberIntervalVo vo = list.get(seat);
				if(seat == realIndex){
					vo.IntervalTimes();
					continue;
				}
				vo.missTimes();
			}
		}
	}
	/**
	 * 显示这次开出的数字在总平均次数间隔只内的数字
	 * @return
	 */
	public List<NumberIntervalVo> showAvgNumber(){
		List<NumberIntervalVo> avgShow = new ArrayList<NumberIntervalVo>();
		for(NumberIntervalVo vo : list){
			if(vo.hasShowAvg()){
				avgShow.add(vo);
			}
		}
		return avgShow;
	}
	
	public List<NumberIntervalVo> getNumberIntervalVoList(){
		return Collections.unmodifiableList(list);
	}
}
